<?php echo $this->Html->script('jquery.dataTables.js'); ?>
 

<script type="text/javascript">
    $(document).ready(function() {
        $('#browserList').dataTable({
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": "<?php echo $this->Html->Url(array('controller' => 'Customers', 'action' => 'indexdata')); ?>"
        });
    });
</script>

    <div class="admin_left actions">

    <h3 style="font-size:20px;">Manage more</h3>

        <ul>
            <li style="list-style-type:none; margin-bottom:20%;"><?php echo $this->Html->link(__('List Groups'), array('controller' => 'groups', 'action' => 'index'),array('class' => 'consistentButton')); ?> </li>
            <li style="list-style-type:none; margin-bottom:20%;"><?php echo $this->Html->link(__('New Group'), array('controller' => 'groups', 'action' => 'add'),array('class' => 'consistentButton')); ?> </li>
        </ul>
    </div>




    <div id="pinkHeader" class="admin_right items index" >


            <?php if ($current_customer['group_id'] == '1'): ?>


                <div class="customers index">
                    <h2><?php echo __('Customers'); ?></h2>

        			<p  class="actions" style="list-style-type:none; margin-bottom:2%;"><?php echo $this->Html->link(__('Add New Customer'), array('action' => 'add')); ?></p>

<table id="browserList" style="width:120%;" cellpadding="0" cellspacing="0" class="table table-bordered  table-hover">
    <thead>
        <tr>
            <th style="width:5%;">Id</th>
            <th style="width:13%;">First Name</th>
            <th style="width:13%;">Last Name</th>
            <th style="width:8%;">Username</th>       
            <th style="width:25%;">Email</th>          
            <th style="width:45%;">Action</th>         
        </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan="4" class="dataTables_empty">Loading data from server...</td>
        </tr>
    </tbody>
</table>
<!--
                    <table style="width:120%;" cellpadding="0" cellspacing="0" class="table table-bordered  table-hover">
                        <tr>
                                <th><?php echo $this->Paginator->sort('id'); ?></th>
                                <th style="width:10%;"><?php echo $this->Paginator->sort('first_name'); ?></th>
                                <th  style="width:10%;"><?php echo $this->Paginator->sort('last_name'); ?></th>

                                <th style="width:8%;"><?php echo $this->Paginator->sort('username'); ?></th>
                                <th><?php echo $this->Paginator->sort('email'); ?></th>
                                <th style="width:40%;" class="actions"><?php echo __('Actions'); ?></th>
                        </tr>

                        <?php foreach ($customers as $customer): ?>

                            <tr id="customer_<?php echo h($customer['Customer']['id']); ?>" class="customer">
                                <td><?php echo h($customer['Customer']['id']); ?>&nbsp;</td>
                                <td><?php echo $this->html->link($customer['Customer']['first_name'], array('controller' => 'customers', 'action' => 'view', $customer['Customer']['id'])); ?>&nbsp;</td>
                                <td  style="width:8%;"><?php echo $this->html->link($customer['Customer']['last_name'], array('controller' => 'customers', 'action' => 'view', $customer['Customer']['id'])); ?>&nbsp;</td>
                                <td style="width:8%;"><?php echo h($customer['Customer']['username']); ?>&nbsp;</td>
                                <td><?php echo h($customer['Customer']['email']); ?>&nbsp;</td>

                                <td style="width:50%;" class="actions">
                                    <?php echo $this->Html->link(__('View / Edit'), array('action' => 'edit', $customer['Customer']['id'])); ?>
                                    <?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $customer['Customer']['id']), null, __('Are you sure you want to delete # %s?', $customer['Customer']['id'])); ?>
				    <?php echo $this->Html->link(__('Reset Password'), array('action' => 'resetPassword', $customer['Customer']['id'])); ?>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </table>-->
                </div>
            <?php else: ?>

            <?php echo "You can't view this page"; ?>
            <?php endif; ?>
			
    </div>

    <script type="text/javascript">
    //<![CDATA[
         var customers = <?php echo json_encode($customers);?>;

         $('#CustomerKeyword').keyup(function(e) {
             if (this.value != '') {
                 for (k in customers) {
                     if ( customers[k]['Customer'].id == this.value||
                     customers[k]['Customer'].first_name.toLowerCase() == this.value.toLowerCase() ||
                             customers[k]['Customer'].last_name.toLowerCase() == this.value.toLowerCase() ||
                             customers[k]['Customer'].username.toLowerCase() == this.value.toLowerCase() ||
                              customers[k]['Customer'].id.indexOf(this.value)>= 0 ||
                              customers[k]['Customer'].first_name.toLowerCase().indexOf(this.value.toLowerCase())>= 0 ||
                              customers[k]['Customer'].last_name.toLowerCase().indexOf(this.value.toLowerCase())>= 0 ||
                              customers[k]['Customer'].username.toLowerCase().indexOf(this.value.toLowerCase())>= 0
                              ) {
                         $('#customer_'+customers[k]['Customer'].id).show();
                     }
                     else {
                         $('#customer_'+customers[k]['Customer'].id).hide();
                     }
                 }
             }
             else {
                 $('.customer').show();
             }
         });
    //]]>
    </script>
    
    
   
